package com.sweetguy.util;

import com.alipay.easysdk.kernel.Config;

/** @author JoeZhou */
public class AlipayUtil {

    /** 应用ID */
    private static final String APPID = "9021000143670929";
    /** 异步通知接口（下单成功后支付宝回调） */
    private static final String NOTIFY_URL = "http://f58872f.r36.cpolar.top/api/v1/order/prePayNotify";
    /** 支付宝公钥 */
    private static final String ALIPAY_PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA" +
            "vD/znRYCbxNIHj3bPQ7tdWcqZ2O2cUI0e1pMrcX4p5I227u+JnPtGc6UngLPfSWX6g4UaJrRm4K0LaA7stqu" +
            "jz0/yY6ruTG5FJ5ertzW6YAK+rj/MnhxWWbLz1qKkG7i3reiqGUm/JdXbV1wFXR8ILw9xXp7us9vH6M2d8W5" +
            "TsbdARBBxDXwa0Cc7w6oaL1eIaCcFVKCHtwlxj+Bd9Hu6pTkfszN8IN4tgS0xU8yUE+eycsUTHNNhC1JuIOI" +
            "6QSYqy/GVJXH9z+VELpY+id62e/paz2znfvdpwBnJLNGOZ5YiAq6yzABSQc8nz0QyhAzZu9QMxQbBtYcPVm8" +
            "HwplqwIDAQAB";
    /** 应用私钥 */
    private static final String MERCHANT_PRIVATE_KEY = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSk" +
            "AgEAAoIBAQCB5ybLFiox4VMUz95steLaG54DHnLg5T1EHjQGsOHCRsBZ3hs7/GVAi5SrvDbi33SpZkz40lO" +
            "jIGawQznGBmtw7n9/l0bcapVfrgsdZrOlgRaIphYcSx5R+gQ/iryFHCslTfyf48iiDF3DshgoITGALTgSdl" +
            "STFXzmpaOeF0rEszpcpkDSddeyII5PuP1mlUnyWKvyHDnlv6OZ3JFfhPw5Q9h+h4zVKUkvJBMOAt9RyJc9b" +
            "4Y3hWATAprQRuwM4znX0eruYafdCEeZ261tLMJqB4ZE6xzYYfzACGG2fIy8vY6/XJmZYybXiN12OHlLCfQe" +
            "d9ZV3vuEEqULsIsnt2AfAgMBAAECggEBAIFuYl3JyOMIQnKjJ1ij5dMx3z/2T7o7Ts8XVPkxts+PFUq1nec" +
            "n9W7ZZJm0n+9vfFrpHlpxnnoT551Kbj8b2GOejxT/EtC9tfWugU6bLPYD6ALhkXhBdIVzmlYBkxMB3Q9/Y+" +
            "2f1SF5NtetFJqvcBXpeEwU8PHYYCmj8qGrTYksKB4r4sXvJtxssQ/MYSQfGln8R02dYscyahzVzZVOlsxAM" +
            "H0OvsvYGIFx2FzgQicZAzIsP6mO/q6ITh703Q1/9WYNTBxaOyV3sgKzrrcj4XJiZTFYPLqWpS+Ev+8vI5kt" +
            "Rh6ztYbQ4hn0ptRbgXfsbCokcQu4df+v01QB98+bLAECgYEA0nxl1fXpcwlLUxalTw9RgrPXzIuSxUhfRZ6" +
            "rItlQop8EEL/ukVAUovNNbR25PrlMcN1QI3YL/QjndUe92GNJl18Tqdv/LqIyk6jUiMc2KWzREPQ/Z7Xz95" +
            "KM1IpqLgVcefT+KH5BjLvpzBvkeFa3ObdBbzphfm+xxLGfkWNuLh8CgYEAnf4F+dAR6nokdBQ5HxAeq2qnH" +
            "YQmLlC2MyJGsstMJIZFTBzlDBXTws/BPE7Geyd3WqRTFMd6SaIO1Xsptl3dgmkNB9a/7D6dXE1/Dj5mH6ad" +
            "chTv+kOaW3MwJemKtFZUXLf7l10GMdE7clcbr/3wvZmbc3fFafKEtIGkUVrMjgECgYAGFT5ELrUuc+hPYGo" +
            "qnMC4TEZCTQ5S0UKfmnRLr4gbCwltCn70iCHwi6ODMca2v1gsMtksDS9PgsBdrVMZO9VWoJLK5+a6DEn15n" +
            "0t7sPr8o8gNE7YynNghkW3psBm0BTaGXB27x8p2Axrr6qsp6Tn8BneAwvqQYQbsR5xbzQx9QKBgB4Hz8j5J" +
            "L6l8tHhmi3uWXYJsrQojz1UeB1mEXwgqlty7i8Weu7+Ix8vcDJvYsi76rLe8y/K7tKaLCml3HregqEsKJ7p" +
            "0dcs26pUzKa/c5fmipzJoAe429kwHuHF72hx1F0/V2Ig+3FyrNMB/bBJG35eeS7MgEiwIUtSLRKNqL4BAoG" +
            "BAIzSmAusqpyqx6y6roTF3hqvCn9D/uVgoSC0Uh4JO4ViDazLl7Kvs3mHbyoidu3XSCTCfcGJVcnKanPYEt" +
            "vJF/iF7EoMCITEUdDVxQewgmuWgHXzPUe24QskpBHM4kxYMfmJAc1BLk1uwspbjnVV5uIXSZw7i2vm9Sd6z" +
            "mgAFHbg";
    /** 单例的Alipay配置对象 */
    private static volatile Config config;
    /** 单例对外方法 */
    public static Config getConfig() {
        if (config == null) {
            synchronized (AlipayUtil.class) {
                if (config == null) {
                    config = new Config();
                    config.protocol = "https";
                    config.gatewayHost = "openapi-sandbox.dl.alipaydev.com";
                    config.signType = "RSA2";
                    config.ignoreSSL = true;
                    config.appId = APPID;
                    config.alipayPublicKey = ALIPAY_PUBLIC_KEY;
                    config.merchantPrivateKey = MERCHANT_PRIVATE_KEY;
                    config.notifyUrl = NOTIFY_URL;
                }
            }
        }
        return config;
    }
}